Employee Updater: Building a Client-Server Application with Macromedia Flash Data Connection Wizard and ColdFusion
Table of Contents
Logging Out
Next, you'll create a logout button. To make it easy to switch between the login and logout buttons, and the buttons you'll add for insert, delete, and save, you''ll put the logout button on a separate form:
- Add another form to the application and name it navLogout.
- Select navLogout in the form tree and go to the
Property inspector. Set the
visibleparameter tofalse. You do not want the Insert, Delete, Save, and Logout buttons to display on startup (before a user logs in). - Select the navLogout form and add a Button component to it. In the Property inspector, name the instance buttonLogout. Set W=75, H=22, X=460, Y=370. Click the label field and set it to Logout.
- Click the new Logout button in the navLogout form and open the Actions panel.
-
Type the following code in the Actions panel:
// Process logout on (click) { // Hide logout buttons _root.application.navLogout.visible=false; // Show login button _root.application.navLogin.visible=true; // No more editable _root.application.data.empDataGrid.editable=false; } -
The above code ensures that upon log-out, the SWF hides the Logout button and displays Login button again. The opposite needs to occur upon log-on, so select the login form and the authService component, and insert the following two lines before the comment that reads
// Close login popup:// Hide login buttons _root.application.navLogin.visible=false; // Show logout button _root.application.navLogout.visible=true;
- Save the changes and run the application. You should be able to log in and log out as needed. When you log in, the code lets you edit the employees in the grid and displays the Logout button; when you log out, the code prevents you from being able to edit and displays the Login button again.